package com.example.demo.ui.home;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.fragment.NavHostFragment;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

import com.example.demo.R;
import com.example.demo.databinding.ActivityItemDetailBinding;
import com.example.demo.databinding.ActivityMainPageBinding;
import com.example.demo.placeholder.PlaceholderContent;
import com.google.android.material.appbar.CollapsingToolbarLayout;

public class ItemDetailHostActivity extends AppCompatActivity {

    /**
     * The fragment argument representing the item ID that this fragment
     * represents.
     */
    public static final String ARG_ITEM_ID = "item_id";

    /**
     * The placeholder content this fragment is presenting.
     */
    private PlaceholderContent.PlaceholderItem mItem;
    private CollapsingToolbarLayout mToolbarLayout;
    private TextView mTextView;


    private ActivityItemDetailBinding binding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getSupportActionBar().hide();
        binding = ActivityItemDetailBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        mTextView = binding.itemDetail;
        mToolbarLayout = binding.toolbarLayout;
        updateContent();
    }

    private void updateContent() {
        if(null == mItem){
            mItem = new PlaceholderContent.PlaceholderItem("1233",
                    "麻辣土豆丝",
                    "麻辣土豆丝\n今日能刘昂少麻辣土豆丝\n今日能刘昂少麻辣土豆丝\n今日能刘昂少麻辣土豆丝\n今日能刘昂少麻辣土豆丝\n今日能刘昂少");
        }
        if (mItem != null) {
            mTextView.setText(mItem.details);
            if (mToolbarLayout != null) {
                mToolbarLayout.setTitle(mItem.content);
            }
        }
    }
}